﻿// =================================================================== 
// 项目说明
//====================================================================
// 文件： ERP_CustomerReturnDetail.cs
// 创建时间：2016/12/5
// 负责人：
// ===================================================================
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using CRMMis.Model;
using CRMMis.IDAL;


namespace MSSQLDAL
{
    /// <summary>
    /// 数据层实例化接口类  接收客户退货情表.
    /// </summary>
    public partial class ERP_CustomerReturnDetailDAL : IERP_CustomerReturnDetailDAL
    {
		//此处写查询数据的sql语句，


        //if QueryDataString==""，DAL层的GetList，GetRecordCount等函数将直接存取ERP_CustomerReturnDetail表


        //if QueryDataString!=""，则DAL层的GetList，GetRecordCount等函数将存取该SQL语句，取代表
		//注意：所写sql语句执行结果的字段必须是唯一的

		private const string QueryDataString = @"select a.*,
b.BatchNo,b.ProduceDate,b.DisinfectionDate,b.ExpiryDate,b.AsepticDate,
p.StoreRoomId,(select STOREROOM_NAME from VIEW_STORE where STOREROOM_ID = p.StoreRoomId) StoreRoomName,
d.Supplyprice,(d.Supplyprice * a.Count) TotalPrice,
e.CargoName,e.CargoCode,e.Spec,e.Version,e.Area,e.ProduceName,e.Unit,e.Spell,
f.Supplyprice CusSupplyprice,(f.Supplyprice * a.Count) CusTotalPrice,
g.CargoName CusCargoName,g.CargoCode CusCargoCode,g.Spell CusSpell
from ERP_CustomerReturnDetail a
inner join ERP_CustomerReturn p on p.CustomerReturnId = a.DCustomerReturnId
inner join ERP_StockDetail b on b.ItemId = a.ItemId
inner join ERP_StockInfo c on c.StoreId = b.StoreId
inner join ERP_Cargo_Detail d on d.DetailId = c.DetailId
inner join ERP_Cargo e on e.CargoId = d.CargoId
inner join ERP_CusCargo_Detail f on f.DetailId = a.CusDetailId
inner join ERP_CusCargo g on g.CargoId = f.CargoId";
	}
}
